package com.lambda;

import com.base.Base;
import org.junit.Test;

import java.util.function.UnaryOperator;

/**
 * 实例方法引用
 */
public class InstantMethodUse extends Base {
    String put(String str) {
        System.out.println(str);
        return "hello";
    }

    @Override
    public String toUpCase(String s) {
        return s.toUpperCase();
    }

    public int compaire(int a,int b){
        return a>b?a:b;
    }

    //调用当前实例的方法
    @Test
   public void test() {
        UnaryOperator<String> unaryOperator = this::toUpCase;
        System.out.println(unaryOperator.apply("this inst method"));
        //调用父类的实例方法
        UnaryOperator<String> u1 = super::toUpCase;
        System.out.println(u1.apply("use super upCase method"));
    }
}
